﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using InkFx.WinControl.Core;

namespace InkFx.WinControl
{
    [ToolboxItem(false)]
    public class XIDEFrame : System.Windows.Forms.UserControl
    {
        private Image m_Icon = null;
        private string m_Text = string.Empty;

        [Browsable(true), EditorBrowsable(EditorBrowsableState.Always), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public Image Icon
        {
            get { return m_Icon; }
            set { m_Icon = value; }
        }

        [Browsable(true), EditorBrowsable(EditorBrowsableState.Always), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public override string Text
        {
            get { return m_Text; }
            set { m_Text = (value ?? string.Empty).Trim(); }
        }


        [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false)]
        public bool IsDesignMode
        {
            get { return this.DesignMode/*InkFx.WinControl.Form.IsDesignMode*/; }
        }

        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);

            ////如果控件的可显示区域太小, 则控件将不显示 
            ////之所以要这样, 是因为设置了 IDEPanel 的 WS_CLIPCHILDREN 后, 如果 此IDEFrame中是一个 ListView 控件, 
            ////当 ListView 的显示高度很小时, ListView 会发生消息的死循环, 用 Spy++拦截发现: ListView 死循环的是 NM_CUSTOMDRAW 消息
            //var size = this.Size;
            //var visible = size.Width >= 5 && size.Height >= 5;
            //this.Visible = visible;
        }
    }
}
